package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-23
 * Time: 21:51
 * name: 查找图书操作
 */
public class FindOperation implements IOperation{

    //查找功能

    @Override
    public void way(BookList bookList) {
        System.out.println("查找图书! ");
        System.out.println("请输入需要查找的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int len = bookList.getCountsize();

        for (int i = 0; i < len; i++) {
            Book book = bookList.getpos(i);
            if(name.equals(book.getName())){
                System.out.println("已找到，系统中有此书！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("系统中无此书！");
    }
}
